** construction regressions using place-level annual data by regulation

set trace off
set more 1 
capture log close
clear
clear matrix
set mem 31g
set matsize 11000
set maxvar 32767
set linesize 200
version 9

log using table4.log, replace

use placeann.dta if sfus~=., clear
drop if dlrgasp1at==. | husf80==.
drop if cbsa==.
drop if micro==1
egen nobs = count(sfus), by(newid)

tab year, gen(y)
tab year if nobs==28
egen msayear = group(cbsa year)
reg sfus dlrgasp1t24up dlrgasp2t24up dlrgasp3t24up dlrgasp4t24up dlrgasp1d dlrgasp2d dlrgasp3d dlrgasp4d dlfrm1t24up dlfrm2t24up dlfrm3t24up dlfrm4t24up  dlgdp1t24up dlgdp2t24up dlgdp3t24up dlgdp4t24up [w=husf80]
keep if e(sample)
drop if hdens80==.
keep sfus dlrgasp1t24up dlrgasp2t24up dlrgasp3t24up dlrgasp4t24up dlrgasp1d dlrgasp2d dlrgasp3d dlrgasp4d dlfrm1t24up dlfrm2t24up dlfrm3t24up dlfrm4t24up  dlgdp1t24up dlgdp2t24up dlgdp3t24up dlgdp4t24up husf80 cbsa newid msayear year msa msa99 cbsaname wharton hdens80
rename msa msanecma

merge m:1 cbsa using mfgshare
tab _merge
drop if _merge==2
drop _merge


* PANEL A: MFG SHARE AND HOUSING DENSITY

egen mark = tag(newid) if hdens80~=. & mfgshare80~=.
sum hdens80 if mark==1, det
gen p50hdens80 = r(p50)


gen supplycat = 1 if mfgshare80>.33 & mfgshare80~=. 
replace supplycat = 2 if mfgshare80<=.33 & hdens80>p50hdens80 & hdens80~=.
replace supplycat = 3 if mfgshare80<=.33 & hdens80<=p50hdens80 & hdens80~=.

tab supplycat if mark==1

xi: areg sfus dlrgasp1t24up dlrgasp2t24up dlrgasp3t24up dlrgasp4t24up dlrgasp1d dlrgasp2d dlrgasp3d dlrgasp4d dlfrm1t24up dlfrm2t24up dlfrm3t24up dlfrm4t24up  dlgdp1t24up dlgdp2t24up dlgdp3t24up dlgdp4t24up  i.newid [w=husf80] if supplycat==1, cluster(cbsa) absorb(msayear)
lincom dlrgasp1t24up+dlrgasp2t24up+dlrgasp3t24up+dlrgasp4t24up
lincom dlrgasp1d+dlrgasp2d+dlrgasp3d+dlrgasp4d
lincom dlfrm1t24up+dlfrm2t24up+dlfrm3t24up+dlfrm4t24up
lincom dlgdp1t24up+dlgdp2t24up+dlgdp3t24up+dlgdp4t24up
sum sfus if e(sample), det

xi: areg sfus dlrgasp1t24up dlrgasp2t24up dlrgasp3t24up dlrgasp4t24up dlrgasp1d dlrgasp2d dlrgasp3d dlrgasp4d dlfrm1t24up dlfrm2t24up dlfrm3t24up dlfrm4t24up  dlgdp1t24up dlgdp2t24up dlgdp3t24up dlgdp4t24up  i.newid [w=husf80] if supplycat==2, cluster(cbsa) absorb(msayear)
lincom dlrgasp1t24up+dlrgasp2t24up+dlrgasp3t24up+dlrgasp4t24up
lincom dlrgasp1d+dlrgasp2d+dlrgasp3d+dlrgasp4d
lincom dlfrm1t24up+dlfrm2t24up+dlfrm3t24up+dlfrm4t24up
lincom dlgdp1t24up+dlgdp2t24up+dlgdp3t24up+dlgdp4t24up
sum sfus if e(sample), det

xi: areg sfus dlrgasp1t24up dlrgasp2t24up dlrgasp3t24up dlrgasp4t24up dlrgasp1d dlrgasp2d dlrgasp3d dlrgasp4d dlfrm1t24up dlfrm2t24up dlfrm3t24up dlfrm4t24up  dlgdp1t24up dlgdp2t24up dlgdp3t24up dlgdp4t24up  i.newid [w=husf80] if supplycat==3, cluster(cbsa) absorb(msayear)
lincom dlrgasp1t24up+dlrgasp2t24up+dlrgasp3t24up+dlrgasp4t24up
lincom dlrgasp1d+dlrgasp2d+dlrgasp3d+dlrgasp4d
lincom dlfrm1t24up+dlfrm2t24up+dlfrm3t24up+dlfrm4t24up
lincom dlgdp1t24up+dlgdp2t24up+dlgdp3t24up+dlgdp4t24up
sum sfus if e(sample), det

* PANEL B: MFG SHARE AND WHARTON REGULATION INDEX
drop supplycat
gen supplycat = 1 if mfgshare80>.33 & mfgshare80~=.
replace supplycat = 2 if mfgshare80<=.33 & wharton>=0 & wharton~=.
replace supplycat = 3 if mfgshare80<=.33 & wharton<0

xi: areg sfus dlrgasp1t24up dlrgasp2t24up dlrgasp3t24up dlrgasp4t24up dlrgasp1d dlrgasp2d dlrgasp3d dlrgasp4d dlfrm1t24up dlfrm2t24up dlfrm3t24up dlfrm4t24up  dlgdp1t24up dlgdp2t24up dlgdp3t24up dlgdp4t24up  i.newid [w=husf80] if supplycat==2, cluster(cbsa) absorb(msayear)
lincom dlrgasp1t24up+dlrgasp2t24up+dlrgasp3t24up+dlrgasp4t24up
lincom dlrgasp1d+dlrgasp2d+dlrgasp3d+dlrgasp4d
lincom dlfrm1t24up+dlfrm2t24up+dlfrm3t24up+dlfrm4t24up
lincom dlgdp1t24up+dlgdp2t24up+dlgdp3t24up+dlgdp4t24up
sum sfus if e(sample), det

xi: areg sfus dlrgasp1t24up dlrgasp2t24up dlrgasp3t24up dlrgasp4t24up dlrgasp1d dlrgasp2d dlrgasp3d dlrgasp4d dlfrm1t24up dlfrm2t24up dlfrm3t24up dlfrm4t24up  dlgdp1t24up dlgdp2t24up dlgdp3t24up dlgdp4t24up  i.newid [w=husf80] if supplycat==3, cluster(cbsa) absorb(msayear)
lincom dlrgasp1t24up+dlrgasp2t24up+dlrgasp3t24up+dlrgasp4t24up
lincom dlrgasp1d+dlrgasp2d+dlrgasp3d+dlrgasp4d
lincom dlfrm1t24up+dlfrm2t24up+dlfrm3t24up+dlfrm4t24up
lincom dlgdp1t24up+dlgdp2t24up+dlgdp3t24up+dlgdp4t24up
sum sfus if e(sample), det



quietly log off
quietly log close
set more 0
